package com.gemme.gemme.wode;

import android.os.Build;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.alibaba.fastjson.JSON;
import com.gemme.gemme.BaseActivity;
import com.gemme.gemme.R;
import com.gemme.gemme.manager.DataManager;
import com.gemme.gemme.view.RefreshView;
import com.gemme.gemme.view.SgDDView;
import com.gemme.gemme.view.Topview;
import com.jaeger.library.StatusBarUtil;

import org.json.JSONObject;

import java.util.HashMap;

import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

//侧滑删除地址
public class TuikuanDetailActivity extends BaseActivity{

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_tuikuan_detail);
        initTop();
        initIntentData();
        initView();
    }
    SgDDView sgDDView;
    TextView tv_price;
    TextView tv_error;
    TextView tv_price2;
    TextView tv_time;
    TextView tv_code;
    private void initView() {
        sgDDView = findViewById(R.id.sgDDView);
        tv_price = findViewById(R.id.tv_price);
        tv_error = findViewById(R.id.tv_error);
        tv_price2 = findViewById(R.id.tv_price2);
        tv_time = findViewById(R.id.tv_time);
        tv_code = findViewById(R.id.tv_code);

    }


    int id;
    DingdanListBean.DataBean dataBean;
    private void initIntentData() {
        try {

            id = getIntent().getIntExtra("data",-1);
            if(id > -1){
                getData();
            }
        }catch (Exception e){

        }
    }

    private void getData() {
        String url = DataManager.BaseUrl_panghu + "mall/shoporderdetail/" + id;



        HashMap<String, String> headMap = new HashMap<>();
        headMap.put(DataManager.AuthorizationKey,DataManager.getToken(mContext));
        DataManager.toServer2(mContext, url, DataManager.GET_TYPE, "", headMap, new DataManager.GeResponse() {
            @RequiresApi(api = Build.VERSION_CODES.O)
            @Override
            public void onResponse(String response) {
                try {

                    JSONObject jsonObject = new JSONObject(response);

                    String data = jsonObject.getJSONObject("data").getString("wholeOrderVo");
                    JSONObject jbInfo = jsonObject.getJSONObject("data").getJSONObject("paddressResquersVo");

                    dataBean = JSON.parseObject(data, DingdanListBean.DataBean.class);
                    String addressee = jbInfo.getString("addressee");
                    String address = jbInfo.getString("address");
                    sgDDView.setdata(dataBean);
                    /*tv_name.setText(addressee + "");
                    tv_address.setText(address + "");
                    sgDDView.setdata(dataBean);
                    tv_order_id.setText(dataBean.getOrderId() + "");
                    tv_create_time.setText(dataBean.getCreateTime() + "");
                    tv_brand.setText(dataBean.getBrandName());*/

                    tv_price.setText("¥" + dataBean.getPaymentMoney());
                    tv_price2.setText("退款金额: " + dataBean.getPaymentMoney());
                    tv_time.setText("申请时间: " + dataBean.getCreateTime());
                    tv_code.setText("退款编号: " + dataBean.getOrderId());
                    String re = dataBean.getRemboursement();

                    String re_substring = re.substring(re.indexOf("2{退款原因:") + 7, re.indexOf("}3{上传凭证图片"));
                    tv_error.setText("退款原因:  " + re_substring);
                    System.out.println("");
                }catch (Exception e){

                }

            }
        });
    }


    private void initTop() {
//        StatusBarUtil.setColor(this,getResources().getColor(R.color.white_color) );
        StatusBarUtil.setTransparent(this);
//        StatusBarUtil.setTranslucent(this,250);
        Topview topview = findViewById(R.id.topview);
        topview.setContentText("退款详情");
    }




}